﻿//
// $HeadURL: http://codeka-memcache.googlecode.com/svn/trunk/Codeka.Memcache/Commands/Command.cs $
// $Revision: 5 $
// $Author: dean.codeka $     $Date: 2010-02-19 22:52:37 +0000 (Fri, 19 Feb 2010) $
//
// Copyright © 2009-2010 Dean Harding, all rights reserved.
//


using System.Collections.Generic;
namespace Codeka.Memcache.Commands
{
    /// <summary>
    /// A <see cref="Command"/> is a high-level request that we make to a server.
    /// </summary>
    public abstract class Command
    {
        /// <summary>
        /// Gets or sets a value that indicates whether this <see cref="Command"/> is
        /// queues on the <see cref="ServerConnection"/>. If <c>false</c> it means we
        /// must be currently executing.
        /// </summary>
        public bool IsQueued { get; set; }

        /// <summary>
        /// Get an <see cref="IEnumerable{T}"/> collection of <see cref="Packet"/>s that
        /// we want to send to the server.
        /// </summary>
        public abstract IEnumerable<Packet> GetPackets();

        /// <summary>
        /// Processes the given response <see cref="Packet"/> and return <c>true</c>
        /// if we're expecting more or <c>false</c> otherwise.
        /// </summary>
        /// <param name="pkt">The <see cref="Packet"/> to process.</param>
        /// <returns><c>true</c> if we're expecting more packets in resposne or
        /// <c>false</c> if this is the last one.</returns>
        public abstract bool ProcessResponse(Packet pkt);
    }
}
